﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
    <script src="/lib/date/wdatepicker.js"></script>
</head>
<body style="background-color: white;">
    <section class="container-fluid" style="background-color: white;">
        <form class="form-horizontal m15_t" id="form">
            <div class="tab-content">
                <input type="hidden" id="announcementId" name="announcementId" value="0">
                <div class="tab-pane fade in active" id="home">
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>标题：</label>
                        <div class="wd300 m15_l">
                            <input class="form-control" type="text" name="subject" maxlength="40" autocomplete="off" placeholder="长度必须介于 1 和 30 之间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>内容：</label>
                        <div class="wd300 m15_l">
                            <textarea style="height: auto;font-size: 12px;width: 100%;" id="content" name="content" rows="7" maxlength="500"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>公告时间：</label>
                        <div class="wd300 m15_l">
                            <input class="form-control Wdate" type="text" name="sDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" autocomplete="off" placeholder="开始时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>结束时间：</label>
                        <div class="wd300 m15_l">
                            <input class="form-control Wdate" type="text" name="eDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" autocomplete="off" placeholder="结束时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>弹窗提示：</label>
                        <div class="wd300 m15_l">
                            <label class="m10_r">
                                <input type="radio" name="popups" value="1"> 弹窗
                            </label>
                            <label>
                                <input type="radio" name="popups" value="2"> 不弹窗
                            </label>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </section>
</body>
</html>
<script type="text/javascript">

    var id = null;

    function init() {
        var cover = FlashPay.UI.Mask({
            obj: $("body"),
            opacity: 0.5
        });

        FlashPay.Util.Ajax({
            type: "GET",
            url: "/Home/GetSysAnnouncement/" + id,
            data: null,
            success: function (response) {

                if (response.success) {
                    if (response.data != null) {
                        FlashPay.Util.SetInputVal("announcementId", response.data.announcementId);
                        FlashPay.Util.SetInputVal("subject", response.data.subject);
                        $("textarea[name='content']").val(response.data.content);
                        FlashPay.Util.SetInputVal("sDate", response.data.sdate)
                        FlashPay.Util.SetInputVal("eDate", response.data.edate)
                        $("input[name=popups][value='" + response.data.popups + "']").attr("checked", true);
                    }
                    cover.Remove();
                } else {
                    cover.Remove();
                    FlashPay.UI.Tip_short_warning(response.errorMessage);
                }
            },
            error: function (e) {

                cover.Remove();
                FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试");
            }
        });
    }

    $(function () {

        id = FlashPay.Util.GetQueryString("id");

        init();
    })

    function save() {

        var json = {};
        json.announcementId = $("input[name='announcementId']").val();
        json.subject = $("input[name='subject']").val();
        json.content = $("textarea[name='content']").val();
        json.sDate = $("input[name='sDate']").val();
        json.eDate = $("input[name='eDate']").val();
        var popups = $(":radio[name='popups']:checked").val();
        if (FlashPay.Util.isNullOrEmptySpance(popups)) {
            FlashPay.UI.Tip_short_warning("请选择弹窗提示！");
            return;
        }
        json.popups = popups;

        FlashPay.Util.Ajax({
            url: '/Home/SaveOrEdit',
            type: 'POST',
            data: json,
            success: function (response) {
                if (response.success) {
                    FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                    FlashPay.UI.DialogOpener().Announcement();
                    FlashPay.UI.CloseDialog();
                } else {
                    FlashPay.UI.Tip_short_warning("操作失败！" + response.errorMessage);
                }
            },
            error: function (json) {
                FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试!");
            }
        });
    }
</script>